package com.yly.common.basic.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.yly.constant.Constant;

public class BasicAction extends ActionSupport implements ServletRequestAware,
		ServletResponseAware, SessionAware {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2933620279072741102L;

	private Map<String, Object> session = new HashMap<String, Object>();

	private HttpServletRequest request;

	private HttpServletResponse response;

	protected Map<String, String> param = new HashMap<String, String>();

	@SuppressWarnings("rawtypes")
	private Map rparam = new HashMap();
	
	public Map<String, String> getParam() {
        return this.param;
    }

    public void setParam(Map<String, String> param) {
        this.param = param;
    }

    

    @SuppressWarnings("rawtypes")
	public Map getRparam() {
		return rparam;
	}

	@SuppressWarnings("rawtypes")
	public void setRparam(Map rparam) {
		this.rparam = rparam;
	}

	public String get(String key){
        return this.param.get(key);
    }
    
    @SuppressWarnings("unchecked")
	public void put(String key, Object object) {
		this.rparam.put(key, object);
	}
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void putAll(Map map) {
		this.rparam.putAll(map!=null?map:new HashMap());
	}

	public Map<String, Object> getSession() {
		return this.session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	/* (非 Javadoc)
	* <p>Title: setServletResponse</p>
	* <p>Description: </p>
	* @param arg0
	* @see org.apache.struts2.interceptor.ServletResponseAware#setServletResponse(javax.servlet.http.HttpServletResponse)
	*/
	@Override
	public void setServletResponse(HttpServletResponse request) {
		this.response = response;
	}

	/* (非 Javadoc)
	* <p>Title: setServletRequest</p>
	* <p>Description: </p>
	* @param arg0
	* @see org.apache.struts2.interceptor.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)
	*/
	@Override
	public void setServletRequest(HttpServletRequest response) {
		this.request = request;
	}


}
